package br.ufpb.di.knowledgetv.sqtv.inference.builtins;

import br.ufpb.di.knowledgetv.algorithms.LetterPairSimilarity;
import com.hp.hpl.jena.graph.Node;
import com.hp.hpl.jena.reasoner.rulesys.RuleContext;
import com.hp.hpl.jena.reasoner.rulesys.builtins.BaseBuiltin;

/**
 * User: manoel
 * Date: 08/07/13
 */
public class CompareString extends BaseBuiltin {

    @Override
    public String getName() {
        return "compareString";
    }

    @Override
    public int getArgLength() {
        return 2;
    }

    @Override
    public boolean bodyCall(Node[] args, int length, RuleContext context) {
        Node arg0 = args[0];
        Node arg1 = args[1];
        double d = LetterPairSimilarity.compareStrings( (String)arg0.getLiteralValue(), (String)arg1.getLiteralValue() );
        if( d > 0.6 )
            return true;
        else
            return false;
    }
}
